#!/bin/bash

# 定义一个路径变量
run_packages_path=$1

# 如果没有传入参数，则输出提示信息
if [ -z "$run_packages_path" ]; then
    echo "Usage: $0 [run_packages_path]"
    exit 1
fi

# 如果传入的路径不存在，则输出提示信息
if [ ! -d "$run_packages_path" ]; then
    echo "Error: $run_packages_path is not a directory."
    exit 1
fi

# 获取${run_packages_path}目录下的所有.run文件,依次执行
files=$(ls -v ${run_packages_path}/*.run)
for file in $files; do
    # 检查文件是否存在
    if [ -e "$file" ]; then
        echo "Running ${file}"
        sh "${file}"
    fi
done
